<?php


//通过session获取会员信息
function user_info(){
    $map['uid'] = session('uid');
    $arr = M('User')->where($map)->find();  
    return $arr;
}

//获取网站名称等
function get_web(){
	$map['id'] = 1;
    $info = M('Setup')->where($map)->find();
	return $info;
}

//获取内容数量
function get_show_sum(){
	$sum = array(
		'news' => M('News')->count(),
		'mood' => M('Mood')->count(), 
		'photo' => M('Photo')->count(), 
	);
	return $sum;
}

//获取粉丝数量
function get_wx_sum(){
	$map['regtime'] = strtotime(date('Y-m-d'));
	$sum = array(
		'wx' => M('Wxuser')->count(),
		'now' =>M('Wxuser')->where($map)->count(),
	);
	return $sum;
}

  function guid(){
	if (function_exists('com_create_guid')){
		return com_create_guid();
	}else{	
		mt_srand((double)microtime()*10000);
		$charid = strtoupper(md5(uniqid(rand(), true)));
		$hyphen = chr(45);
		$uuid = substr($charid, 0, 8).substr($charid, 8, 4).substr($charid,12, 4).substr($charid,16, 4).substr($charid,20,12);
		return $uuid;
	}
  }
  
 //微信 
  //获取AccessToken End
function get_wx_access_token(){
	$Com = new \Common\Wechat\WxAccess;
    $WxAccessToken = $Com->WxAccessToken();
    return $WxAccessToken;
}  

//curl函数 处理请求
function http_curl($url,$type='get',$res='json',$arr=''){
    $ch  = curl_init();
        curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($ch,CURLOPT_SSLVERSION, 1);
        curl_setopt($ch,CURLOPT_HEADER, 0); // 过滤HTTP头
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
     if($type == 'post'){
		curl_setopt($ch,CURLOPT_HEADER, 0); // 过滤HTTP头
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
        curl_setopt($ch,CURLOPT_POST,1);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$arr);
        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     }
    $output =curl_exec($ch);
        curl_close($ch);
        if($res=='json'){
            if(curl_error($ch)){
                return curl_error($ch);
            }else{
                return json_decode($output,true);
            }
        } 
}		
//微信分享配置
function wx_share(){
	$Share = new \Common\Wechat\WxJsSdk;
	$WxShare = $Share->wxShare();
	return $WxShare;
}